package com.liuzy.dto;

import lombok.Data;
import org.springframework.http.ResponseEntity;

@Data
public class JsonRet {
    public static final JsonRet SUCCESS = new JsonRet("00", "成功");
    public static final JsonRet FAILED = new JsonRet("99", "失败");
    private String status;
    private String message;
    private Object data;

    public JsonRet() {
    }

    public JsonRet(String status, String message) {
        this.status = status;
        this.message = message;
    }

    public static ResponseEntity<JsonRet> ok() {
        return ResponseEntity.ok(SUCCESS);
    }

    public static ResponseEntity<JsonRet> ok(Object obj) {
        JsonRet jsonRet = new JsonRet("00", "成功");
        jsonRet.setData(obj);
        return ResponseEntity.ok(jsonRet);
    }

    public static ResponseEntity<JsonRet> no() {
        return ResponseEntity.ok(FAILED);
    }
}
